package com.sgb.kjwl.view.ui.fragment.home;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.launcher.ARouter;
import com.amap.api.maps.AMap;
import com.amap.api.maps.AMapOptions;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.MyLocationStyle;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.core.PoiItem;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.RegeocodeAddress;
import com.amap.api.services.geocoder.RegeocodeQuery;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.amap.api.services.poisearch.PoiResult;
import com.amap.api.services.poisearch.PoiSearch;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.fondesa.recyclerviewdivider.DividerDecoration;
import com.google.android.material.appbar.AppBarLayout;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.api.UrlConfig;
import com.swgk.core.event.MessageEvent;
import com.sgb.kjwl.databinding.FragmentFreightTransport4Binding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.model.entity.CarInfo;
import com.sgb.kjwl.model.entity.MaterialMenuEntity;
import com.sgb.kjwl.view.ui.activity.MainActivity;
import com.sgb.link.entity.PickFilterEntity;
import com.sgb.kjwl.model.entity.UserMsgEntity;
import com.sgb.kjwl.model.entity.self.PermissionMenuEntity;
import com.sgb.kjwl.model.entity.self.TypeChooseEntity;
import com.sgb.kjwl.model.entity.transport.CarTypeAndCarLength;
import com.sgb.kjwl.model.entity.transport.GoodsHallFilterEntity;
import com.sgb.kjwl.model.entity.transport.GoodsInfoTypeEntity3;
import com.sgb.kjwl.model.entity.transport.ManageListEntity;
import com.sgb.kjwl.model.entity.transport.MapSourcesEntity;
import com.sgb.kjwl.model.entity.transport.VehicleHallMapEntity;
import com.sgb.kjwl.model.entity.transport.WeightAndVolumeEntity;
import com.sgb.kjwl.service.LocationService;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.DefaultUtil;
import com.sgb.kjwl.utils.LocationUtil;
import com.sgb.kjwl.utils.NumberUtil;
import com.sgb.kjwl.utils.PickerHelper;
import com.swgk.core.util.UserOperating;
import com.sgb.kjwl.utils.VehicleConstant;
import com.sgb.kjwl.view.event.CategoryEvent;
import com.swgk.core.event.EventConstant;
import com.sgb.kjwl.view.event.GoodsSourceSearchEvent;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.event.LogisticsEvent;
import com.sgb.kjwl.view.ui.activity.demand.DemandManageActivity;
import com.sgb.kjwl.view.ui.activity.home.HomeCategoryActivity;
import com.sgb.kjwl.view.ui.activity.logistics.LogisticsSearchActivity3;
import com.sgb.kjwl.view.ui.activity.manage.ManageActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.manage.special.InviteMemberListActivity;
import com.sgb.kjwl.view.ui.activity.self.AddCarInfoActivity;
import com.sgb.kjwl.view.ui.activity.self.authentication.AuthActivity;
import com.sgb.kjwl.view.ui.activity.self.authentication.AuthActivity3;
import com.sgb.kjwl.view.ui.activity.self.logistics.AddCarActivity;
import com.sgb.kjwl.view.ui.activity.transport.BiddingTransportHallActivity;
import com.sgb.kjwl.view.ui.activity.transport.DriverLookForGoodsActivity;
import com.sgb.kjwl.view.ui.activity.transport.GoodsCarsActivity;
import com.sgb.kjwl.view.ui.activity.transport.ProfessionalSalesActivity;
import com.sgb.kjwl.view.ui.activity.transport.ProfessionalServicesActivity;
import com.sgb.kjwl.view.ui.activity.vehicleManagement.AddDriverInfoActivity;
import com.sgb.kjwl.view.ui.adapter.YoungAdapterOnItemClick;
import com.sgb.kjwl.view.ui.adapter.transport.CarLengthTransportAdapter3;
import com.sgb.kjwl.view.ui.adapter.transport.CarTypeTransportAdapter3;
import com.sgb.kjwl.view.ui.adapter.transport.HomeManageCompanyListAdapter;
import com.sgb.kjwl.view.ui.adapter.transport.HomeManageTabAdapter;
import com.sgb.kjwl.view.ui.adapter.transport.WeightAndVolumeMinAndMaxAdapter;
import com.sgb.kjwl.view.ui.fragment.transport.CarsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.GoodsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.LogisticsMenuFragment;
import com.sgb.kjwl.view.widget.SjSelectDialog;
import com.sgb.kjwl.view.widget.packers.TeamMainCompanyPupWindow;
import com.sgb.kjwl.view.widget.transport.ChooseTypePopWindow;
import com.sgb.kjwl.view.widget.transport.menu.LogisticsMenuAdapter;
import com.sgb.kjwl.viewmodel.home.FreightTransportFragModel4;
import com.sgb.link.entity.AMapAddressEntity;
import com.sgb.link.entity.MenuEntity;
import com.sgb.link.router.PathTransport;
import com.sgb.link.router.PathUser;
import com.sgb.link.service.MapService;
import com.sgb.link.view.adapter.PageRecycleAdapter;
import com.sgb.member.ui.activity.MemberInviteOrApplyActivity;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.base.model.entity.RouterKey;
import com.swgk.core.dialog.RoundCornerDialog;
import com.swgk.core.dialog.RoundDialog;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.adapter.SlidingFragmentPagerAdapter;
import com.swgk.core.recyclerview.adapter.TransportAdapterOnItemClick;
import com.swgk.core.recyclerview.decoration.RecyclerCustomDecoration;
import com.swgk.core.refresh.SuperSwipeRefreshLayout;
import com.swgk.core.util.CheckUtils;
import com.swgk.core.util.MLog;
import com.swgk.core.util.MToast;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.weiget.TopView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * 2020-8-25  物流首页
 * Description:
 * Author
 */
public class FreightTransportFragment4 extends AppLazyFragment implements AMap.OnMyLocationChangeListener, GeocodeSearch.OnGeocodeSearchListener, PoiSearch.OnPoiSearchListener {
    @Inject
    FreightTransportFragModel4 model;
    private FragmentFreightTransport4Binding binding;
    public static final String KEY_TYPE = "type";
    private int pattern = 0;

    @Autowired(name = PathUser.AMapDialog)
    public MapService mapService;

    private boolean isVisible;
    private boolean isCreate = false;
    private boolean init = true;
    private Context mContext;

    private String[] titles = {"找货车", "找货源", "货运竞价", "返程预定"};
    private SlidingFragmentPagerAdapter pagerAdapter;
    private ArrayList<Fragment> mFragments;
    private String managerAuth = "";
    private String driverAuth = "";
    private int mCurrentIndex = 0;//记录当前tab所在位置 选择可视找货/可视找车 退出后回到此位置
    private boolean isChooseMap = false;//tab是否选择了可视，跳转地图的
    AlertDialog mDialog;
    private boolean isHasRightPublishGoodsPutong = false;//是否有权利发布普通货源
    private boolean isHasRightPublishGoodsJingjia = false;//是否有权利发布竞价货源
    private boolean isHasRightPublishCarriage = false;//是否有权利发布承运

    private List<CarInfo> carInfo;
    UserMsgEntity data;

    UserMsgEntity dataPermission;
    boolean isCloose;//是否已关闭车辆完善提示
    CarInfo carInfoEntity;
    //定位服务
    private Intent mLocationServiceIntent;
    private boolean isShowLocService;

    private TextureMapView mapView;
    private AMap aMap;
    GeocodeSearch geocodeSearch;

    List<VehicleHallMapEntity> listCars;
    List<MapSourcesEntity> listGoods;
    LatLng latLng;
    boolean hasPermissionLocation;//是否获取到定位
    boolean isSettingPositionFinish = false;//装货地址是否设定成功（通过定位获取的或者设定了默认位置）

    private ChooseTypePopWindow carTypePop;
    private ChooseTypePopWindow carFunctionPop;
    private ChooseTypePopWindow goodsTypePop;//货物类型选择框
    private OptionsPickerView<TypeChooseEntity> weightPicker;//重量选择器
    private OptionsPickerView<TypeChooseEntity> radiusPicker;//重量选择器
    private String typeNos = "";
    private String functionNos = "";
    private String goodsTypeNos = "";//选中的货源类型No
    private String maxWeight = "";
    private String minWeight = "";

    private final List<TypeChooseEntity> weightBeans = new ArrayList<>();
    private final List<TypeChooseEntity> radiusBeans = new ArrayList<>();
    private int selectWeightPosition = 0;
    private int selectRadiusPosition = 0;//默认不限公里
    //选中的货物类型集合
    private ArrayList<TypeChooseEntity> goodsTypeEntities = new ArrayList<>();
    //选中的车型集合
    private ArrayList<TypeChooseEntity> carTypeEntities = new ArrayList<>();
    //选中的车辆功能集合
    private ArrayList<TypeChooseEntity> carFunctionEntities = new ArrayList<>();

    //0——我要找车，1——我要找货
    private int findType = 0;

    LogisticsMenuAdapter adapterAllMenu;

    /**
     * 装货地地址信息
     * 需要传递给地图找车页面
     */
    private AMapAddressEntity startAddress = new AMapAddressEntity();
    private AMapAddressEntity endAddress;

    //地图搜索Poi类型
    private final static String POI_TYPE = "汽车服务|汽车销售|汽车维修|摩托车服务|餐饮服务|购物服务|生活服务|" +
            "体育休闲服务|医疗保健服务|住宿服务|风景名胜|商务住宅|政府机构及社会团体|科教文化服务|" +
            "金融保险服务|公司企业|道路附属设施|公共设施";

    HomeManageTabAdapter adapter;
    HomeManageCompanyListAdapter companyListAdapter;
    List<ManageListEntity> mListLeague;//会员列表
    List<ManageListEntity> mListMember;//成员列表
    List<ManageListEntity> mListFocus;//关注列表
    private TeamMainCompanyPupWindow mMainCompany;

    public static FreightTransportFragment4 newInstance(String type) {
        FreightTransportFragment4 fragment = new FreightTransportFragment4();
        Bundle bundle = new Bundle();
        bundle.putString(KEY_TYPE, type);
        fragment.setArguments(bundle);
        return fragment;
    }

    private Handler mHandler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message msg) {
            binding.bgPopGrayLayout.setVisibility(View.VISIBLE);
            return false;
        }
    });

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        if (isVisibleToUser) {//物流首页正在显示判断定位权限是否授权
            isShowLocService = false;
            checkLocServiceEnable();
        }
        super.setUserVisibleHint(isVisibleToUser);
        isVisible = isVisibleToUser;
        if (!isCreate) {
            return;
        }
        if (isVisibleToUser) {
            if (init) {
                init = false;
                //init();
            }
        }
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        isCreate = true;
        ARouter.getInstance().inject(this);
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent.builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mContext = getContext();
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_freight_transport4, container, false);
        binding.mapView.onCreate(savedInstanceState);
        binding.wstvFindCar.setSelected(true);
        binding.wstvFindGoods.setSelected(false);
        return binding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
    }

    public void initViews() {
//        binding.tabBuy.setOnClickListener(this);
        goodsSourceFilterEntity = new GoodsHallFilterEntity();
        binding.tvPublic.setOnClickListener(this);
        binding.tvBusiness.setOnClickListener(this);
        binding.tvQuoted.setOnClickListener(this);
        binding.closeImperfect.setOnClickListener(this);
        binding.toImperfect.setOnClickListener(this);
        binding.sureStep.setOnClickListener(this);
        binding.containerMenuDown.setOnClickListener(this);
        binding.containerMenuUp.setOnClickListener(this);
        binding.tvManageEmpty.setOnClickListener(this);
        binding.tvInviteType.setOnClickListener(this);
        binding.ivOpenCompanyList.setOnClickListener(this);
        binding.resetStep.setOnClickListener(v -> resetAllFilterData());

        binding.drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);//禁止抽屉侧滑出来

        binding.swipeRefresh.setOnPullRefreshListener(new SuperSwipeRefreshLayout.OnPullRefreshListener() {
            @Override
            public void onRefresh() {
                textView.setText("正在刷新");
//                model.getMenuModel("");
//                showRecommendList(null);
                Observable.timer(0, TimeUnit.MILLISECONDS)
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(aLong -> {
                            EventBus.getDefault().post(LogisticsEvent.make().setMessageTag(EventConstant.EVENT_LOGISTICS_REFRESH));
                            binding.swipeRefresh.setRefreshing(false);
                            getMapList();
                        });
                isDefaultStyle = true;
                binding.ttvTop.setCheckedPosition(0);
                binding.ttvTop.closeExpand(false);
                binding.rlShowAllMenu.setVisibility(View.GONE);
                binding.rlShowPageMenu.setVisibility(View.VISIBLE);

                EventBus.getDefault().postSticky(EventConstant.EVENT_REFRESH_MAIN_GOODS_TYPES);//去刷新一级货物类型
            }

            @Override
            public void onPullDistance(int distance) {

            }

            @Override
            public void onPullEnable(boolean enable) {
                textView.setText(enable ? "释放立即刷新" : "下拉刷新");
            }
        });
        binding.swipeRefresh.setHeaderView(createHeaderView());
        binding.swipeRefresh.setEnabled(false);
        binding.appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
                if (i >= 0) {
                    binding.swipeRefresh.setEnabled(true);
                } else {
                    binding.swipeRefresh.setEnabled(false);
                }
            }
        });

        initWeightRecyclerView();
        initVolumeRecyclerView();
        initCarTypeView();
        initCarLengthView();

        model.typesAndLensLD.observe(this, new Observer<List<CarTypeAndCarLength>>() {
            @Override
            public void onChanged(List<CarTypeAndCarLength> carTypeAndCarLengths) {
                setCarTypeAndCarLength(carTypeAndCarLengths);
            }
        });

        carTypePop = new ChooseTypePopWindow(getContext(), "选择车型");
        carTypePop.setOnResultClick((key1, key2, key3) -> {
            List<TypeChooseEntity> entity = (List<TypeChooseEntity>) key1;
            inputCarType(entity);
        });
        carTypePop.setOnDismissListener(() -> setBgDim(1f));

        carFunctionPop = new ChooseTypePopWindow(getContext(), "选择车辆功能");
        carFunctionPop.setOnResultClick((key1, key2, key3) -> {
            List<TypeChooseEntity> entity = (List<TypeChooseEntity>) key1;
            inputCarFunction(entity);
        });
        carFunctionPop.setOnDismissListener(() -> setBgDim(1f));

        goodsTypePop = new ChooseTypePopWindow(getContext(), "选择货物类型");
        goodsTypePop.setContainUnlimited(false);
        goodsTypePop.setOnResultClick((key1, key2, key3) -> {
            List<TypeChooseEntity> entity = (List<TypeChooseEntity>) key1;
            inputGoodsType(entity);
        });
        goodsTypePop.setOnDismissListener(() -> setBgDim(1f));

        weightBeans.add(new TypeChooseEntity("不限", 0, 0f));
        weightBeans.add(new TypeChooseEntity("0-10吨", 0, 10f));
        weightBeans.add(new TypeChooseEntity("10-30吨", 10, 30f));
        weightBeans.add(new TypeChooseEntity("30-50吨", 30, 50f));
        weightBeans.add(new TypeChooseEntity("50-100吨", 50, 100f));
        weightBeans.add(new TypeChooseEntity("100-500吨", 100, 500f));
        weightBeans.add(new TypeChooseEntity("500-1000吨", 500, 1000f));
        weightBeans.add(new TypeChooseEntity("1000吨以上", 1000, 99999f));

        weightPicker = PickerHelper.with(getContext()).getCommonPicker(weightBeans, (options1, options2, options3, v) -> {
            selectWeightPosition = options1;
            inputGoodsWeight(options1);
        });
        weightPicker.setTitleText("货物重量");
        radiusBeans.add(new TypeChooseEntity("0","不限"));
        radiusBeans.add(new TypeChooseEntity("10", "10公里内"));
        radiusBeans.add(new TypeChooseEntity("50", "50公里内"));
        radiusBeans.add(new TypeChooseEntity("100", "100公里内"));
        radiusBeans.add(new TypeChooseEntity("200", "200公里内"));
        radiusBeans.add(new TypeChooseEntity("300", "300公里内"));
        radiusBeans.add(new TypeChooseEntity("500", "500公里内"));

        radiusPicker = PickerHelper.with(getContext()).getCommonPicker(radiusBeans, (options1, options2, options3, v) -> {
            selectRadiusPosition = options1;
            inputRadius(options1);
        });
        radiusPicker.setTitleText("半径");
        radiusPicker.setSelectOptions(0);
    }

    @Override
    protected void onLazyLoad() {
        initViews();
        init();
    }

    // Header View
    private ProgressBar progressBar;
    private TextView textView;

    private View createHeaderView() {
        View headerView = LayoutInflater.from(binding.swipeRefresh.getContext())
                .inflate(R.layout.super_swipe_refresh_head, null);
        progressBar = headerView.findViewById(R.id.pb_view);
        textView = headerView.findViewById(R.id.text_view);
        textView.setText("下拉刷新");
        progressBar.setVisibility(View.GONE);
        return headerView;
    }

    private void init() {
        initMenuView();
        initTabManage();
        showRecommendList(null);
        checkUserCarInfo();
        initMap();
        startLocation();
        binding.setOnClick(this);

        listCars = new ArrayList<>();
        listGoods = new ArrayList<>();

        model.ldCars.observe(this, list -> {
            this.listCars = list;
            if (binding.wstvFindCar.isSelected()) {
                addMarkerCars(listCars);
            }
        });
        model.ldGoods.observe(this, list -> {
            this.listGoods = list;
            if (binding.wstvFindGoods.isSelected()) {
                addMarkerGoods(listGoods);
            }
        });

        if (UserOperating.getInstance().isLogged()) {
//            model.getLeaguerList(1);
            binding.tvManageEmpty.setVisibility(View.VISIBLE);
            binding.tvManageEmpty.setText("暂无数据");
        } else {
            binding.tvManageEmpty.setVisibility(View.VISIBLE);
            binding.tvInviteType.setVisibility(View.GONE);
            binding.tvManageEmpty.setText("您暂未登录，请登录后查看");
        }
        model.ldManageList.observe(this, this::showManageList);
        model.ldGetAllList.observe(this, result -> {
            showCompanyPop();
        });

        model.ldCarType.observe(this, entity3s -> handleCarTypes(entity3s));
        model.ldCarFunction.observe(this, entity3s -> handleCarFunctions(entity3s));
        model.ldGoodsType.observe(this, entity3s -> {
            handleGoodsTypes(entity3s);
            if (adapterAllMenu != null) {
                List<MenuEntity> listdata = new ArrayList<>();
                MenuEntity menuEntity;
                for (GoodsInfoTypeEntity3 entity3 : entity3s) {
                    menuEntity = new MenuEntity();
                    menuEntity.setName(entity3.getName());
                    menuEntity.setId(entity3.getNo());
                    menuEntity.setAppIcon(entity3.getKingKongDiagram());
                    listdata.add(menuEntity);
                }
                adapterAllMenu.setDatas(listdata);
            }
        });

        model.getCarFunction();
        model.getGoodsType();
        model.getCarTypeList();
    }

    /**
     * 处理车型数据
     *
     * @param entities
     */
    private void handleCarTypes(List<GoodsInfoTypeEntity3> entities) {
        if (entities != null && entities.size() > 0) {
            List<TypeChooseEntity> chooseEntities = new ArrayList<>();
            for (GoodsInfoTypeEntity3 entity : entities) {
                TypeChooseEntity entity1 = new TypeChooseEntity();
                entity1.setSelect(false);
                entity1.setName(entity.getName());
                entity1.setNo(entity.getNo());
                if (carTypeEntities.size() > 0) {
                    for (TypeChooseEntity en : carTypeEntities) {
                        if (entity.getNo().equals(en.getNo())) {
                            entity1.setSelect(true);
                        }
                    }
                }
                chooseEntities.add(entity1);
            }
            carTypePop.setData(chooseEntities);
        }
    }

    /**
     * 录入车型
     *
     * @param entity
     */
    private void inputCarType(List<TypeChooseEntity> entity) {
        if (entity == null)
            return;

        typeNos = "";

        carTypeEntities.clear();
        carTypeEntities.addAll(entity);

        List<String> strings = new ArrayList<>();
        String carTypeStr = "";
        for (TypeChooseEntity typeEntity : carTypeEntities) {
            if (!TextUtils.isEmpty(typeEntity.getName())) {
                carTypeStr = carTypeStr + typeEntity.getName() + "/";
            }
            if (!TextUtils.isEmpty(typeEntity.getNo())) {
                strings.add(typeEntity.getNo());
                typeNos += typeEntity.getNo() + ",";
            }
        }
        if (typeNos.length() > 0) {
            typeNos = typeNos.substring(0, typeNos.length() - 1);
        }

        if (carTypeStr.length() > 0) {
            carTypeStr = carTypeStr.substring(0, carTypeStr.length() - 1);
        }

        if (TextUtils.isEmpty(carTypeStr)) {
            binding.carType.setText("请选择");
            binding.carType.setTextColor(Color.parseColor("#C0C4CC"));
        } else {
            binding.carType.setText(carTypeStr.trim());
            binding.carType.setTextColor(Color.parseColor("#333333"));
        }
    }

    /**
     * 处理车辆功能数据
     *
     * @param entities
     */
    private void handleCarFunctions(List<GoodsInfoTypeEntity3> entities) {
        if (entities != null && entities.size() > 0) {
            List<TypeChooseEntity> chooseEntities = new ArrayList<>();
            for (GoodsInfoTypeEntity3 entity : entities) {
                TypeChooseEntity entity1 = new TypeChooseEntity();
                entity1.setSelect(false);
                entity1.setName(entity.getName());
                entity1.setNo(entity.getNo());
                if (carFunctionEntities.size() > 0) {
                    for (TypeChooseEntity en : carFunctionEntities) {
                        if (entity.getNo().equals(en.getNo())) {
                            entity1.setSelect(true);
                        }
                    }
                }
                chooseEntities.add(entity1);
            }
            carFunctionPop.setData(chooseEntities);
        }
    }

    /**
     * 录入车辆功能
     *
     * @param entity
     */
    private void inputCarFunction(List<TypeChooseEntity> entity) {
        if (entity == null)
            return;
        carFunctionEntities.clear();
        carFunctionEntities.addAll(entity);
        functionNos = "";

        String carFunStr = "";
        if (entity.size() > 0) {
            for (TypeChooseEntity typeEntity : carFunctionEntities) {
                if (!TextUtils.isEmpty(typeEntity.getName())) {
                    carFunStr = carFunStr + typeEntity.getName() + "/";
                }
                if (!TextUtils.isEmpty(typeEntity.getNo())) {
                    functionNos += typeEntity.getNo() + ",";
                }
            }
        }
        if (!TextUtils.isEmpty(functionNos)) {
            functionNos = functionNos.substring(0, functionNos.length() - 1);
        }
        if (!TextUtils.isEmpty(carFunStr)) {
            carFunStr = carFunStr.substring(0, carFunStr.length() - 1);
        }

        if (TextUtils.isEmpty(carFunStr)) {
            binding.carFunction.setText("请选择");
            binding.carFunction.setTextColor(Color.parseColor("#C0C4CC"));
        } else {
            binding.carFunction.setText(carFunStr.trim());
            binding.carFunction.setTextColor(Color.parseColor("#333333"));
        }
    }

    /**
     * 处理货物类型数据
     *
     * @param entities
     */
    private void handleGoodsTypes(List<GoodsInfoTypeEntity3> entities) {
        List<TypeChooseEntity> chooseEntities = new ArrayList<>();
        if (entities != null && entities.size() > 0) {
            for (GoodsInfoTypeEntity3 entity : entities) {
                TypeChooseEntity entity1 = new TypeChooseEntity();
                entity1.setSelect(false);
                entity1.setName(entity.getName());
                entity1.setNo(entity.getNo());
                if (goodsTypeEntities.size() > 0) {
                    for (TypeChooseEntity en : goodsTypeEntities) {
                        if (entity.getNo().equals(en.getNo())) {
                            entity1.setSelect(true);
                        }
                    }
                }
                chooseEntities.add(entity1);
            }
        }
        goodsTypePop.setData(chooseEntities);
    }

    /**
     * 录入货物类型
     *
     * @param entity
     */
    private void inputGoodsType(List<TypeChooseEntity> entity) {
        goodsTypeNos = "";
        goodsTypeEntities.clear();
        if (entity == null || entity.size() == 0 || (entity.size() > 0 && entity.get(0).getName().equals("不限"))) {
            binding.goodsType.setText("请选择");
            binding.goodsType.setTextColor(Color.parseColor("#C0C4CC"));
            return;
        }
        goodsTypeEntities.addAll(entity);
        String goodsTypeStr = "";

        if (entity.size() > 0) {
            for (TypeChooseEntity typeEntity : goodsTypeEntities) {
                if (!TextUtils.isEmpty(typeEntity.getName())) {
                    goodsTypeStr = goodsTypeStr + typeEntity.getName() + "/";
                }
                if (!TextUtils.isEmpty(typeEntity.getNo())) {
                    goodsTypeNos += typeEntity.getNo() + ",";
                }
            }
            if (goodsTypeNos.length() > 0) {
                goodsTypeNos = goodsTypeNos.substring(0, goodsTypeNos.length() - 1);
            }

            if (goodsTypeStr.length() > 0) {
                goodsTypeStr = goodsTypeStr.substring(0, goodsTypeStr.length() - 1);
            }
        }

        if (TextUtils.isEmpty(goodsTypeStr)) {
            binding.goodsType.setText("请选择");
            binding.goodsType.setTextColor(Color.parseColor("#C0C4CC"));
        } else {
            binding.goodsType.setText(goodsTypeStr.trim());
            binding.goodsType.setTextColor(Color.parseColor("#333333"));
        }
    }

    /**
     * 录入货物重量
     */
    private void inputGoodsWeight(int options) {
        if (weightBeans.size() >= options + 1) {
            if (options == 0) {
                binding.weight.setText("请选择");
                binding.weight.setTextColor(Color.parseColor("#C0C4CC"));
                maxWeight = "";
                minWeight = "";
                return;
            }
            TypeChooseEntity entity = weightBeans.get(options);
            //重量
            String weightStr = "";
            if (entity.getMinValue() >= 0) {
                minWeight = entity.getMinValue() + "";
                weightStr += NumberUtil.trim0(entity.getMinValue());
            } else {
                minWeight = "";
            }

            if (entity.getMaxValue() > 0) {
                maxWeight = entity.getMaxValue() + "";
                if (entity.getMinValue() == 1000) {
                    weightStr += "吨以上";
                } else
                    weightStr += "-" + NumberUtil.trim0(entity.getMaxValue()) + "吨";
            } else {
                maxWeight = "";
                weightStr += "吨以上";
            }

            if (TextUtils.isEmpty(weightStr)) {
                binding.weight.setText("请选择");
                binding.weight.setTextColor(Color.parseColor("#C0C4CC"));
            } else {
                binding.weight.setText(weightStr.trim());
                binding.weight.setTextColor(Color.parseColor("#333333"));
            }
        }
    }

    /**
     * 录入半径
     */
    private void inputRadius(int options) {
        if (radiusBeans.size() >= options + 1) {
            TypeChooseEntity entity = radiusBeans.get(options);
            //重量
            String radiusStr = "";
            if (entity != null) {
                radiusStr = entity.getName();
            }
            if (TextUtils.isEmpty(radiusStr)) {
                binding.radius.setText("不限");
            } else {
                binding.radius.setText(radiusStr.trim());
            }
        }
    }

    /**
     * 初始化会员、成员等tab
     */
    private void initTabManage() {
        mListLeague = new ArrayList<>();
        mListMember = new ArrayList<>();
        mListFocus = new ArrayList<>();
        List<PickFilterEntity> titleList = new ArrayList<>();
        PickFilterEntity pickFilterEntity = new PickFilterEntity();
        pickFilterEntity.setName("推荐");
        pickFilterEntity.setIconResourceID(R.drawable.packer_first_content_title_recommend);
        titleList.add(pickFilterEntity);
        PickFilterEntity pickFilterEntity1 = new PickFilterEntity();
        pickFilterEntity1.setName("关注");
        pickFilterEntity1.setIconResourceID(R.drawable.packer_first_content_title_follow);
        titleList.add(pickFilterEntity1);
        PickFilterEntity pickFilterEntity2 = new PickFilterEntity();
        pickFilterEntity2.setName("会员");
        pickFilterEntity2.setIconResourceID(R.drawable.packer_first_content_title_member_company);
        titleList.add(pickFilterEntity2);
        PickFilterEntity pickFilterEntity3 = new PickFilterEntity();
        pickFilterEntity3.setName("成员");
        pickFilterEntity3.setIconResourceID(R.drawable.packer_first_content_title_member);
        titleList.add(pickFilterEntity3);
        PickFilterEntity pickFilterEntity4 = new PickFilterEntity();
        pickFilterEntity4.setName("商机");
        pickFilterEntity4.setIconResourceID(R.drawable.packer_first_content_title_business_opportunity);
        titleList.add(pickFilterEntity4);
        PickFilterEntity pickFilterEntity5 = new PickFilterEntity();
        pickFilterEntity5.setName("分类");
        pickFilterEntity5.setIconResourceID(R.drawable.packer_first_content_title_classify);
        titleList.add(pickFilterEntity5);
        adapter = new HomeManageTabAdapter(getContext(), titleList);
        binding.rvManageTab.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false));
        DividerDecoration.builder(getContext())
                .colorRes(R.color.transparent)
                .size(15, TypedValue.COMPLEX_UNIT_DIP)
                .build()
                .addTo(binding.rvManageTab);
        binding.rvManageTab.setAdapter(adapter);
        adapter.setItemSelect(true);
        adapter.setMultiSelect(false);
        adapter.setDefItem(0);
        adapter.setMostNumber(3);
        adapter.setCheckDefault(0);
        adapter.setOnItemClick(new YoungAdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity pickFilterEntity, int position) {
                switch (pickFilterEntity.getName()) {
                    case "会员":
                        if (!UserOperating.getInstance().isLogged()) {
                            binding.llManageList.setVisibility(View.GONE);
                            binding.tvManageEmpty.setVisibility(View.VISIBLE);
                            binding.tvInviteType.setVisibility(View.GONE);
                            binding.tvManageEmpty.setText("您暂未登录，请登录后查看");
                        } else {
                            if (mListLeague != null && mListLeague.size() > 0) {
                                companyListAdapter.setDatas(mListLeague.size() > 6 ? mListLeague.subList(0, 6) : mListLeague);
                                binding.llManageList.setVisibility(View.VISIBLE);
                                binding.tvManageEmpty.setVisibility(View.GONE);
                                binding.tvInviteType.setVisibility(View.GONE);
                            } else {
                                model.getLeaguerList(2);
                            }
                        }
                        break;
                    case "成员":
                        if (!UserOperating.getInstance().isLogged()) {
                            binding.llManageList.setVisibility(View.GONE);
                            binding.tvManageEmpty.setVisibility(View.VISIBLE);
                            binding.tvInviteType.setVisibility(View.GONE);
                            binding.tvManageEmpty.setText("您暂未登录，请登录后查看");
                        } else {
                            if (mListMember != null && mListMember.size() > 0) {
                                companyListAdapter.setDatas(mListMember.size() > 6 ? mListMember.subList(0, 6) : mListMember);
                                binding.llManageList.setVisibility(View.VISIBLE);
                                binding.tvManageEmpty.setVisibility(View.GONE);
                                binding.tvInviteType.setVisibility(View.GONE);
                            } else {
                                model.getLeaguerList(1);
                            }
                        }
                        break;
                    case "关注":
                        if (!UserOperating.getInstance().isLogged()) {
                            binding.llManageList.setVisibility(View.GONE);
                            binding.tvManageEmpty.setVisibility(View.VISIBLE);
                            binding.tvInviteType.setVisibility(View.GONE);
                            binding.tvManageEmpty.setText("您暂未登录，请登录后查看");
                        } else {
                            if (mListFocus != null && mListFocus.size() > 0) {
                                companyListAdapter.setDatas(mListFocus.size() > 6 ? mListFocus.subList(0, 6) : mListFocus);
                                binding.llManageList.setVisibility(View.VISIBLE);
                                binding.tvManageEmpty.setVisibility(View.GONE);
                                binding.tvInviteType.setVisibility(View.GONE);
                            } else {
                                model.getAttendCompanyList(1, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""));
                            }
                        }
                        break;
                    case "推荐":
                        binding.llManageList.setVisibility(View.GONE);
                        binding.tvManageEmpty.setVisibility(View.VISIBLE);
                        binding.tvInviteType.setVisibility(View.GONE);
                        if (!UserOperating.getInstance().isLogged()) {
                            binding.tvManageEmpty.setText("您暂未登录，请登录后查看");
                        } else {
                            binding.tvManageEmpty.setText("暂无数据");
                        }
                        break;
                    default:
                        MToast.showToast(getContext(), "此功能未开放");
                        break;
                }
            }
        });


        companyListAdapter = new HomeManageCompanyListAdapter(getContext(), null);
        binding.rvManageList.setLayoutManager(new GridLayoutManager(getContext(), 3));
        binding.rvManageList.setAdapter(companyListAdapter);
        companyListAdapter.setItemSelect(true);
        companyListAdapter.setMultiSelect(false);
        companyListAdapter.setCount(6);
        companyListAdapter.setOnItemClick(new AdapterOnItemClick<ManageListEntity>() {
            @Override
            public void onItemClick(ManageListEntity entity, int position) {
                WebsiteInfoActivity.start(getContext(), entity.getCompanyNo(), 1);
            }
        });

    }

    private void showManageList(List<ManageListEntity> list) {
        if (null != list && list.size() > 0) {
            if (adapter.getCheckDatas() != null && adapter.getCheckDatas().size() > 0) {
                if (model.typeMenu == 2) {
                    mListLeague.clear();
                    mListLeague.addAll(list);
                } else if (model.typeMenu == 3) {
                    mListMember.clear();
                    mListMember.addAll(list);
                } else if (model.typeMenu == 1) {
                    mListFocus.clear();
                    mListFocus.addAll(list);
                }
            }
            binding.llManageList.setVisibility(View.VISIBLE);
            binding.tvManageEmpty.setVisibility(View.GONE);
            binding.tvInviteType.setVisibility(View.GONE);
            companyListAdapter.setDatas(list.size() > 6 ? list.subList(0, 6) : list);
        } else {
            companyListAdapter.setDatas(null);
            binding.llManageList.setVisibility(View.GONE);
            binding.tvManageEmpty.setVisibility(View.VISIBLE);
            binding.tvInviteType.setVisibility(View.VISIBLE);
            if (adapter.getCheckDatas() != null && adapter.getCheckDatas().size() > 0) {
                PickFilterEntity currentItem = adapter.getCheckDatas().get(0);
                if (currentItem.getName().equals("会员")) {
                    binding.tvManageEmpty.setText("您还没有会员企业，快去邀请吧！");
                    binding.tvInviteType.setText("邀请会员");
                } else if (currentItem.getName().equals("成员")) {
                    binding.tvManageEmpty.setText("您还没有成员企业，快去邀请吧！");
                    binding.tvInviteType.setText("邀请成员");
                } else if (currentItem.getName().equals("关注")) {
                    binding.tvManageEmpty.setText("您还没有关注的企业，快去看看吧！");
                    binding.tvInviteType.setText("企业大全");
                }
            }
        }
    }

    /**
     * 获取地图上 车、货数据
     */
    private void getMapList() {
        model.getCarFormMap(getContext());
        model.getGoodsSourceList(getContext());
    }

    private GridLayoutManager manager;
    private int count = 6;
    boolean isDefaultStyle = true;


    private void initMenuView() {
//        binding.imgMenuContainer.setBackgroundResource(R.mipmap.goods_icon_menu_down);
        binding.ttvTop.setData(model.getContentTitle());

        binding.ttvTop.setTopViewOfInter(new TopView.TopViewOfInter<Integer>() {
            @Override
            public void itemClick(Integer s, List<Integer> parent, int position, int childPosition) {
                switch (position) {
                    case 0:
                        switch (childPosition) {
                            case 0:
                                GoodsCarsActivity.start(getContext(), 0, false);
                                break;
                            case 1:
                                GoodsCarsActivity.start(getContext(), 0, true);
                                break;
                            case 2:
                                BiddingTransportHallActivity.start(getContext());
                                break;
                            case 3:
                                DriverLookForGoodsActivity.start(getContext());
                                break;

                            case 4:
                                ProfessionalSalesActivity.start(mContext, 1);
                                break;

                            case 5:
                                ProfessionalServicesActivity.start(mContext);
                                break;
                            default:
                                MToast.showToast(getContext(), "功能正在开发中");
                                break;
                        }
                        break;
                    case 1:
                        ProfessionalSalesActivity.start(mContext, 2);
                        break;
                    default:
                        MToast.showToast(getContext(), "功能正在开发中");
                        break;
                }
            }
        });

        ArrayList<Fragment> fragments = new ArrayList<>();
        String[] titlesTop = {"货运大厅"};
        fragments.add(LogisticsMenuFragment.newInstance(0));
//        fragments.add(LogisticsMenuFragment.newInstance(1));
//        fragments.add(LogisticsMenuFragment.newInstance(2));
//        fragments.add(LogisticsMenuFragment.newInstance(3));
        SlidingFragmentPagerAdapter pagerAdapter = new SlidingFragmentPagerAdapter(getChildFragmentManager(), fragments, titlesTop);
        binding.viewpagerTopMenu.setAdapter(pagerAdapter);
        binding.viewpagerTopMenu.setOffscreenPageLimit(0);

        adapterAllMenu = new LogisticsMenuAdapter(getActivity(), null);
        binding.rvAllMenu.setAdapter(adapterAllMenu);
        binding.rvAllMenu.setLayoutManager(new GridLayoutManager(getActivity(), 5));
        binding.rvAllMenu.addItemDecoration(new RecyclerCustomDecoration(
                0,
                0,
                0,
                getResources().getDimension(com.sgb.link.R.dimen.dp10)));
        adapterAllMenu.setOnItemClick(new PageRecycleAdapter.OnItemClick<MenuEntity>() {
            @Override
            public void onClick(MenuEntity menuEntity, int position) {
                GoodsCarsActivity.start(getContext(), 0, false, menuEntity.getId());
            }
        });
    }

    /**
     * 初始化地图
     */
    private void initMap() {
        if (aMap != null)
            return;
        mapView = binding.mapView;
        aMap = binding.mapView.getMap();
        aMap.moveCamera(CameraUpdateFactory.zoomTo(13));//缩放比例
        UiSettings uiSettings = aMap.getUiSettings();//地图的UI设置控制器
        uiSettings.setCompassEnabled(false);// 设置指南针是否显示
        uiSettings.setZoomControlsEnabled(false);// 设置缩放按钮是否显示
        uiSettings.setScaleControlsEnabled(false);// 设置比例尺是否显示
        uiSettings.setRotateGesturesEnabled(false);// 设置地图旋转是否可用
        uiSettings.setTiltGesturesEnabled(false);// 设置地图倾斜是否可用
        uiSettings.setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
        uiSettings.setAllGesturesEnabled(false);//禁用所有手势
        uiSettings.setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_RIGHT);
        aMap.setOnMapClickListener(latLng -> {
            gotoMapFind();
        });
    }

    private void startLocation() {
        //开启了定位 并且不是顶部选择地址才展示当前定位
        if (LocationUtil.isOpenLocation(getContext())) {
            //启动显示定位蓝点，false表示隐藏定位蓝点并不进行定位，默认是false。
            aMap.setMyLocationEnabled(true);
            //初始化定位蓝点样式类
            MyLocationStyle myLocationStyle = new MyLocationStyle();
            //定位一次，且将视角移动到地图中心点。
            myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATE);
            // 设置边框的颜色
            myLocationStyle.strokeColor(Color.TRANSPARENT);
            // 设置边框的填充色
            myLocationStyle.radiusFillColor(Color.TRANSPARENT);
            // 设置定位点图片
            myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(R.mipmap.packer_location));
            //自定义定位蓝点图标的锚点
            myLocationStyle.anchor((float) 0.5, 1);
            //设置定位蓝点的Style
            aMap.setMyLocationStyle(myLocationStyle);
            //定位监听
            aMap.setOnMyLocationChangeListener(this);
            //地理搜索类   根据定位获取当前城市和省编码
            geocodeSearch = new GeocodeSearch(getContext());
            geocodeSearch.setOnGeocodeSearchListener(this);

        } else {
            searchByCityAndKeyword("乌鲁木齐");
        }
    }

    @Override
    public void onMyLocationChange(Location location) {
        //逆地理编码查询条件：逆地理编码查询的地理坐标点、查询范围、坐标类型。
        LatLonPoint latLonPoint = new LatLonPoint(location.getLatitude(), location.getLongitude());
        startAddress.setLatitude(location.getLatitude());
        startAddress.setLongitude(location.getLongitude());
        RegeocodeQuery query = new RegeocodeQuery(latLonPoint, 500f, GeocodeSearch.AMAP);
        //异步查询
        geocodeSearch.getFromLocationAsyn(query);
        model.ldFilter.getValue().setLatitude(location.getLatitude());
        model.ldFilter.getValue().setLongitude(location.getLongitude());
        getMapList();
        latLng = new LatLng(location.getLatitude(), location.getLongitude());
    }


    @Override
    public void onRegeocodeSearched(RegeocodeResult regeocodeResult, int i) {
        RegeocodeAddress regeocodeAddress = regeocodeResult.getRegeocodeAddress();
        startAddress.setType(0);
        startAddress.setCity(regeocodeAddress.getCity());
        startAddress.setProvince(regeocodeAddress.getProvince());
        startAddress.setDistrict(regeocodeAddress.getDistrict());
        startAddress.setDistrictNo(regeocodeAddress.getAdCode());
        startAddress.setSnippet(regeocodeAddress.getFormatAddress());
        String adCode = regeocodeAddress.getAdCode();
        if (!TextUtils.isEmpty(adCode) && adCode.length() == 6) {
            String cityCode = adCode.substring(0, 4) + "00";
            String provinceCode = adCode.substring(0, 2) + "0000";
            startAddress.setCityNo(cityCode);
            startAddress.setProvinceNo(provinceCode);
        }

        String formatAddress = regeocodeAddress.getFormatAddress();
        String result = "";
        try {
            result = formatAddress.replace(regeocodeAddress.getProvince(), "")
                    .replace(regeocodeAddress.getCity(), "")
                    .replace(regeocodeAddress.getDistrict(), "")
                    .replace(regeocodeAddress.getTownship(), "")
                    .replace(regeocodeAddress.getNeighborhood(), "")
                    .replace(regeocodeAddress.getStreetNumber() != null ? regeocodeAddress.getStreetNumber().getStreet() : "", "")
                    .replace(regeocodeAddress.getStreetNumber() != null ? regeocodeAddress.getStreetNumber().getNumber() : "", "");
        } catch (RuntimeException exception) {

        }
        binding.loadPlaceEdit.setText(DefaultUtil.getString(!TextUtils.isEmpty(result) ? result : formatAddress, "乌鲁木齐"));
        isSettingPositionFinish = true;
    }

    @Override
    public void onGeocodeSearched(GeocodeResult geocodeResult, int i) {

    }

    /**
     * 通过城市和关键字搜索地区
     */
    public void searchByCityAndKeyword(String cityName) {
        //设置当前城市
        PoiSearch.Query query = new PoiSearch.Query("", POI_TYPE, cityName);
        query.setPageSize(10);
        query.setPageNum(1);
        query.setExtensions("all");
        PoiSearch poiSearch = new PoiSearch(getActivity(), query);
        poiSearch.setOnPoiSearchListener(this);
        poiSearch.searchPOIAsyn();
    }

    @Override
    public void onPoiSearched(PoiResult poiResult, int code) {
        if (code != 1000) {
            return;
        }
        //1000 成功
        //添加地址信息
        List<PoiItem> poiList = poiResult.getPois();
        if (poiList != null && poiList.size() > 0) {
            MLog.d("debug", "搜索成功");
            PoiItem poi = poiList.get(0);
            //添加当前位置信息
            startAddress = new AMapAddressEntity(poi.getProvinceName(), poi.getCityName(), poi.getAdName()
                    , poi.getSnippet(), poi.getTitle(), "0",
                    poi.getLatLonPoint().getLatitude(), poi.getLatLonPoint().getLongitude(),
                    poi.getProvinceCode(), poi.getCityCode(), poi.getAdCode());
            binding.loadPlaceEdit.setText(poi.getTitle());
            isSettingPositionFinish = true;
            model.ldFilter.getValue().setLatitude(poi.getLatLonPoint().getLatitude());
            model.ldFilter.getValue().setLongitude(poi.getLatLonPoint().getLongitude());
            getMapList();
            latLng = new LatLng(poi.getLatLonPoint().getLatitude(), poi.getLatLonPoint().getLongitude());
        } else {
            MLog.d("debug", "没有搜到，请尝试其他关键词");
        }
    }

    @Override
    public void onPoiItemSearched(PoiItem poiItem, int i) {

    }

    @Override
    public void onResume() {
        super.onResume();
        if (!"".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
            model.getUserInfo();
            // model.getPermissionMenu();
        }
        if (binding.tablayout.getTabAt(mCurrentIndex) != null && isChooseMap) {
            Objects.requireNonNull(binding.tablayout.getTabAt(mCurrentIndex)).select();
        }
        if (isVisible && !isShowLocService) {//物流首页正在显示判断定位权限是否授权
            isShowLocService = false;
            checkLocServiceEnable();
        }
        if (mapView != null)
            mapView.onResume();

        /**
         * 重新获取到定位或者关闭定位刷新列表
         */
        if (aMap == null) {
            initMap();
        }
    }


    //物流首页显示时判断
    private void checkLocServiceEnable() {
        if (getContext() == null) {
            return;
        }
        if (!LocationUtil.isLocServiceEnable(getContext())) {
            hasPermissionLocation = false;
            isShowLocService = true;
            new RoundDialog.Builder(getActivity())
                    .title("系统定位服务已关闭")
                    .content("请打开定位服务，以便我们为您提供更近的货源")
                    .confirmCallback(v -> {
                        isShowLocService = false;
                        LocationUtil.openGPS(getContext());
                    })
                    .cancelCallback(v -> {
                        isShowLocService = false;
                    })
                    .dismissListener(v -> {
                        isShowLocService = false;
                    })
                    .show();
        } else {
            if (!hasPermissionLocation) {//没授权定位
                hasPermissionLocation = true;//标记已授权
                startLocation();
            }
        }
    }

    @Override
    public void onMultiClick(View v) {
        switch (v.getId()) {
            //确定筛选
            case R.id.sure_step:
                //更新车型筛选参数
                if (!isChooseFirstDefaultItem(carTypeAdapter.getCheckDatas())) {
                    refreshLastCheckedCarType();
                    goodsSourceFilterEntity.setCarType(lastCarTypeCheckedData);
                } else {
                    lastCarTypeCheckedData.clear();
                    goodsSourceFilterEntity.setCarType(null);
                }
                //更新车长筛选参数
                if (!isChooseFirstDefaultItem(lengthAdapter.getCheckDatas())) {
                    refreshLastCheckedLength();
                    goodsSourceFilterEntity.setLengthType(lastCarLengthCheckedData);
                } else {
                    lastCarLengthCheckedData.clear();
                    goodsSourceFilterEntity.setLengthType(null);
                }
                EventBus.getDefault().post(new GoodsSourceSearchEvent(EventConstant.EVENT_FILTER_SURE, pattern, goodsTypeNo, goodsSourceFilterEntity));
                binding.drawerLayout.closeDrawers();
                break;

            //更多车长信息
            case R.id.car_length_more:
                if (null != lengthAdapter.getDatas() && lengthAdapter.getDatas().size() > 0) {
                    if (lengthAdapter.getDatas().size() < usefulCarsLengthList.size()) {
                        setCarLengthShowState(false);
                    } else {
                        setCarLengthShowState(true);
                    }
                }
                break;

            //更多车型信息
            case R.id.car_type_more:
                if (null != carTypeAdapter.getDatas() && carTypeAdapter.getDatas().size() > 0) {
                    if (carTypeAdapter.getDatas().size() < usefulCarsTypeList.size()) {
                        setCarTypeShowState(false);
                    } else {
                        setCarTypeShowState(true);
                    }
                }
                break;

            case R.id.img_more:
                //工程材料
                EventBus.getDefault().postSticky(CategoryEvent.make(EventConstant.EVENT_CATEGORY_CHOOSE, 0));
                HomeCategoryActivity.start(getActivity());
                break;
            case R.id.ll_more2:
                DemandManageActivity.start(getActivity(), 1);
                break;
            case R.id.et_view:
                LogisticsSearchActivity3.start(getActivity(), 0);
                break;
            case R.id.tv_public://发布
                /* publicTransport();*/
                break;
            case R.id.tv_quoted://竞价
                /*if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    showDialog(0);
                }else{
                    if(managerAuth.equals("SUCCESS")){
                        //货
                        MapGoodsBiddingActivity.start(getActivity());
                    }else if(driverAuth.equals("SUCCESS")){
                        //车
                        MapCarBiddingActivity.start(getActivity());
                    }
                }*/
                break;
            case R.id.tv_business://商机
                /*  business();*/
                break;
            case R.id.close_imperfect:
                isCloose = true;
                binding.carImperfect.setVisibility(View.GONE);
                break;
            case R.id.to_imperfect:
                if (carInfoEntity == null) {
                    return;
                }
                ActivityJump.jumpToActivity(getActivity(), AddCarInfoActivity.class, Pair.create("carNo", Long.valueOf(carInfoEntity.getNo())),
                        Pair.create("carId", Long.valueOf(carInfoEntity.getId())));
                break;
            case R.id.load_place_edit://装货地
                if (mapService != null && startAddress != null)
//                    mapService.launchMap(getActivity(), 0, startAddress.getProvince() + startAddress.getCity() + startAddress.getDistrict());
                    mapService.launchMap(getActivity(), 0, startAddress.getSnippet());

                break;
            case R.id.unload_place_edit://卸货地
                String loadStr = "";
                String unloadStr = "";
                if (startAddress != null) {
                    loadStr = startAddress.getSnippet();
                }
                if (endAddress != null) {
                    unloadStr = endAddress.getSnippet();
                }
                if (mapService != null && !TextUtils.isEmpty(loadStr))
                    mapService.launchMap(getActivity(), 1, TextUtils.isEmpty(unloadStr) ? TextUtils.isEmpty(loadStr) ? "" : loadStr : unloadStr);
                break;

            case R.id.matching_btn:
                if (isSettingPositionFinish) {
                    gotoMapFind();
                }
                break;
        }
    }

    /**
     * 去地图找车/找货
     */
    private void gotoMapFind() {
        ARouter.getInstance().build(PathTransport.FindByMapActivity)
                .withParcelable(com.swgk.core.base.model.entity.RouterKey.DATA, startAddress)
                .withParcelable(com.swgk.core.base.model.entity.RouterKey.DATA1, endAddress)
                .withInt(com.swgk.core.base.model.entity.RouterKey.INT, findType)
                .withInt(com.swgk.core.base.model.entity.RouterKey.INT1, selectWeightPosition)
                .withInt(com.swgk.core.base.model.entity.RouterKey.INT2, selectRadiusPosition)
                .withParcelableArrayList(com.swgk.core.base.model.entity.RouterKey.LIST, goodsTypeEntities)
                .withParcelableArrayList(com.swgk.core.base.model.entity.RouterKey.LIST1, carTypeEntities)
                .withParcelableArrayList(RouterKey.LIST2, carFunctionEntities)
                .navigation();
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.wstv_find_car://找车
                findType = 0;
                if (!binding.wstvFindCar.isSelected()) {
                    binding.wstvFindCar.setSelected(true);
                    binding.wstvFindGoods.setSelected(false);
                    binding.tvLoadPlace.setBackgroundResource(R.drawable.bg_round_text_load_car);
                    binding.chooseFunction.setVisibility(View.VISIBLE);
                    binding.chooseType.setVisibility(View.VISIBLE);
                    binding.chooseGoodsType.setVisibility(View.GONE);
                    binding.chooseWeight.setVisibility(View.GONE);
                    if (listCars != null) {
                        addMarkerCars(listCars);
                    }
                }
                break;
            case R.id.wstv_find_goods://找货
                findType = 1;
                if (!binding.wstvFindGoods.isSelected()) {
                    binding.wstvFindCar.setSelected(false);
                    binding.wstvFindGoods.setSelected(true);
                    binding.tvLoadPlace.setBackgroundResource(R.drawable.bg_round_text_load_goods);
                    binding.chooseFunction.setVisibility(View.GONE);
                    binding.chooseType.setVisibility(View.GONE);
                    binding.chooseGoodsType.setVisibility(View.VISIBLE);
                    binding.chooseWeight.setVisibility(View.VISIBLE);
                    if (listGoods != null) {
                        addMarkerGoods(listGoods);
                    }
                }
                break;
            case R.id.wstv_map_operate://图查
                if (getActivity() instanceof MainActivity) {
                    ((MainActivity) getActivity()).displayFrg(6);
                    ((MainActivity) getActivity()).showTabView(6);
                }
                break;

            case R.id.container_menu_down://展开
//                if (isDefaultStyle2) {
//                    isDefaultStyle2 = false;
//                } else {
//                    isDefaultStyle2 = true;
//                }
//                binding.imgMenuContainer.setBackgroundResource(isDefaultStyle2 ? R.mipmap.goods_icon_menu_up : R.mipmap.goods_icon_menu_down);
                binding.rlShowAllMenu.setVisibility(View.VISIBLE);
                binding.rlShowPageMenu.setVisibility(View.GONE);
                break;
            case R.id.container_menu_up://收起

                binding.rlShowAllMenu.setVisibility(View.GONE);
                binding.rlShowPageMenu.setVisibility(View.VISIBLE);
                break;

            case R.id.choose_type://选择车型
                carTypePop.showDownPopwindow(binding.chooseType, false);
                carTypePop.setTittle("车型");
                carTypePop.setLeftBtnStr("重置");
                setBgDim(0.7f);
                break;

            case R.id.choose_function://选择车辆功能
                carFunctionPop.showDownPopwindow(binding.chooseFunction, false);
                carFunctionPop.setTittle("车辆功能");
                carFunctionPop.setLeftBtnStr("重置");
                carFunctionPop.setSingle(true);
                setBgDim(0.7f);
                break;

            case R.id.choose_goods_type://选择货物类型
                goodsTypePop.showDownPopwindow(binding.chooseGoodsType, true);
                goodsTypePop.setTittle("货物类型");
                goodsTypePop.setLeftBtnStr("重置");
                setBgDim(0.7f);
                break;

            case R.id.choose_weight://选择货物重量
                if (weightPicker != null) {
                    weightPicker.show();
                }
                break;

            case R.id.choose_radius://选择半径
                if (radiusPicker != null) {
                    radiusPicker.show();
                }
                break;
            case R.id.tv_manage_empty://登录
                if (UserOperating.getInstance().isNotLogged(getContext())) {
                    return;
                }
                break;
            case R.id.tv_invite_type://邀请
                if (adapter != null && adapter.getCheckDatas() != null && adapter.getCheckDatas().size() > 0) {
                    PickFilterEntity currentItem = adapter.getCheckDatas().get(0);
                    if (currentItem.getName().equals("成员")) {
                        if (UserOperating.getInstance().isCompany()) {
                            InviteMemberListActivity.launch(getContext());
                        } else {
                            MToast.showToast(getContext(), "请切换为企业身份邀请");
                        }
                    } else if (currentItem.getName().equals("会员")) {
                        MemberInviteOrApplyActivity.startInviteOrApply(getActivity(), 0);
                    } else if (currentItem.getName().equals("关注")) {
                        String longitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LONGITUDE_ID, "");
                        String latitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LATITUDE_ID, "");
                        ActivityJump.jumpToActivity(getActivity(), ManageActivity.class, Pair.create("latitude", latitude), Pair.create("longitude", longitude));
                    }
                }
                break;
            case R.id.iv_open_company_list://关注，会员，推荐，成员相关列表
                if (!UserOperating.getInstance().isNotLogged(getActivity())) {
                    model.getLeaguerOrVipList(1);
                }
                break;
        }
    }

    private void showCompanyPop() {
        if (mMainCompany == null) {
            mMainCompany = new TeamMainCompanyPupWindow(getContext());
        }
        mMainCompany.setDataRecommend(new ArrayList<>());
        mMainCompany.setDataLeaguer(model.companyList.get(1));
        mMainCompany.setDataMember(model.companyList.get(2));
        mMainCompany.setDataAttend(model.companyList.get(3));
        mMainCompany.setClippingEnabled(false);
        if (!mMainCompany.isShowing()) {
            mMainCompany.showPopwindow(binding.ivOpenCompanyList, Gravity.BOTTOM, 0, 0);
        }
    }

    public void business() {
        if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
            showDialog(0);
        } else {

            if (!managerAuth.equals("") || !driverAuth.equals("")) {
                SjSelectDialog dialog = new SjSelectDialog(getActivity(), data, null);
                dialog.setType(0);
                dialog.setClickCallBack(new SjSelectDialog.DialogClickCallBack() {
                    @Override
                    public void dialogContent(String content) {
                        showDialogAuth(content);
                    }
                });
                dialog.show();
            } else {
                showDialog(1);
            }

        }
    }

    public void publicTransport() {
        if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
            showDialog(0);
        } else {
            if (!managerAuth.equals("") || !driverAuth.equals("")) {
                SjSelectDialog dialog = new SjSelectDialog(getActivity(), data, null);
                dialog.setType(1);
                dialog.setCarInfo(carInfo);
                dialog.setClickCallBack(new SjSelectDialog.DialogClickCallBack() {
                    @Override
                    public void dialogContent(String content) {
                        showDialogAuth(content);
                    }
                });
                dialog.show();

            } else {
                showDialog(1);
            }
        }

    }

    //认证dialog
    private void showDialogAuth(String type) {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);

        if (type.equals("manager")) {
            tv_title.setText("认证");
            tv_message.setText("请先进行企业认证再操作");
        } else if (type.equals("driver")) {
            tv_title.setText("认证");
            tv_message.setText("请先进行司机认证再操作");
        } else if (type.equals("nocar")) {
            tv_title.setText("无可用车辆");
            tv_message.setText("请先添加车辆");
            tv_logout_confirm.setText("去添加");
        } else if (type.equals("driverFail")) {
            tv_title.setText("司机认证不通过");
            tv_message.setText("请重新提交认证信息");
        } else if (type.equals("managerFail")) {
            tv_title.setText("企业认证不通过");
            tv_message.setText("请重新提交认证信息");
        } else if (type.equals("driverStandby")) {
            tv_title.setText("司机认证审核中");
            tv_message.setText("认证通过后才能操作");
        } else if (type.equals("managerStandby")) {
            tv_title.setText("企业认证审核中");
            tv_message.setText("认证通过后才能操作");
        }

        //确定
        tv_logout_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (type.equals("manager") || type.equals("managerFail")) {
                    AuthActivity3.start(getActivity());
                } else if (type.equals("driver") || type.equals("driverFail")) {
                    //                  AddVehicleActivity.start(getActivity());
                    Intent intent = new Intent(getActivity(), AddDriverInfoActivity.class);
                    startActivity(intent);
                } else if (type.equals("nocar")) {
                    AddCarActivity.start(getActivity());
                }
                roundCornerDialog.dismiss();
            }
        });

        //取消
        tv_logout_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
            }
        });
    }

    /**
     * 为viewpager添加数据
     *
     * @param datas
     */
    public void showRecommendList(List<MaterialMenuEntity> datas) {
        binding.swipeRefresh.setRefreshing(false);
        mFragments = new ArrayList<>();
        mFragments.add(CarsFragment.newInstance(false));
        mFragments.add(GoodsFragment.newInstance("1", true, true, false));
        mFragments.add(GoodsFragment.newInstance("2", true, true, false));
        mFragments.add(CarrierDemandFragment.newInstance(false, true));
        pagerAdapter = new SlidingFragmentPagerAdapter(getChildFragmentManager(), mFragments, titles);
        binding.viewpager2.setAdapter(pagerAdapter);
        binding.viewpager2.setOffscreenPageLimit(4);
        binding.tablayout.setupWithViewPager(binding.viewpager2);
    }

    //检查当前用户身份校验车辆信息
    public void checkUserCarInfo() {
        if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {//未登录返回
            return;
        }
        if (isCloose) {
            return;
        }
        int type = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
        if (type != 0) {
            binding.carImperfect.setVisibility(View.GONE);
            return;
        }
        model.showcheckCarInfo();

    }


    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(String event) {
        if (event.equals(EventConstant.EVENT_REFRESH_MAIN)) {
            checkUserCarInfo();
            if (mListMember != null) {
                mListMember.clear();
            } else {
                mListMember = new ArrayList<>();
            }
            if (mListLeague != null) {
                mListLeague.clear();
            } else {
                mListLeague = new ArrayList<>();
            }
            if (mListFocus != null) {
                mListFocus.clear();
            } else {
                mListFocus = new ArrayList<>();
            }
            if (adapter != null && adapter.getCheckDatas().size() > 0) {
                PickFilterEntity currentItem = adapter.getCheckDatas().get(0);
                if (currentItem.getName().equals("会员")) {
                    model.getLeaguerList(2);
                } else if (currentItem.getName().equals("成员")) {
                    model.getLeaguerList(1);
                } else if (currentItem.getName().equals("关注")) {
                    model.getAttendCompanyList(1, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""));
                }

            }
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (mapView != null)
            mapView.onPause();
    }

    @Override
    public void onDestroy() {
        EventBus.getDefault().unregister(this);
        stopLocationService();
        if (mapView != null)
            mapView.onDestroy();
        if (carFunctionPop != null && carFunctionPop.isShowing()) {
            carFunctionPop.dismiss();
            carFunctionPop = null;
        }
        if (carTypePop != null && carTypePop.isShowing()) {
            carTypePop.dismiss();
            carTypePop = null;
        }
        if (goodsTypePop != null && goodsTypePop.isShowing()) {
            goodsTypePop.dismiss();
            goodsTypePop = null;
        }
        super.onDestroy();
    }

    public void startUploadDriverLocation() {
        if (!UserOperating.getInstance().isPersonal()) {
            stopLocationService();
            return;
        }

        if (UserOperating.getInstance().isLogged()
                && UserOperating.getInstance().isAuthDriver()
                && UserOperating.getInstance().getUserInfo() != null
                && UserOperating.getInstance().getUserInfo().isHasCar()) {
            if (!CheckUtils.isServiceRunning(getContext(), "com.sgb.kjwl.service.LocationService")) {
                //判断服务是否在运行，没有则重启
                mLocationServiceIntent = new Intent(getActivity(), LocationService.class);
                getActivity().startService(mLocationServiceIntent);
            } else if (mLocationServiceIntent == null) {
                //判断服务是已启动，没有开启
                mLocationServiceIntent = new Intent(getActivity(), LocationService.class);
                getActivity().startService(mLocationServiceIntent);
            }
        } else {
            stopLocationService();
        }
    }

    private void stopLocationService() {
        if (mLocationServiceIntent != null) {
            getActivity().stopService(mLocationServiceIntent);
            mLocationServiceIntent = null;
        } else if (CheckUtils.isServiceRunning(getContext(), "com.sgb.kjwl.service.LocationService")) {
            Intent intent = new Intent(getActivity(), LocationService.class);
            getActivity().stopService(intent);
        }
    }

    public void showPermission(UserMsgEntity data) {
        this.dataPermission = data;
    }

    /**
     * 是否已认证货运中介
     *
     * @return true：已认证  false：未认证
     */
    @Deprecated
    public boolean isAuthAgentComputer() {
      /*  //todo
        if (UrlConfig.BASE_URL.equals("https://api.sgbwl.com/sgb-app/")) {//测试服判断
            return dataPermission != null
                    && dataPermission.getTeamRespVO() != null
                    && "202012014306139".equals(dataPermission.getTeamRespVO().getBusinessTypeNo());
        }
        return dataPermission != null
                && dataPermission.getTeamRespVO() != null
                && "1333351902414508032".equals(dataPermission.getTeamRespVO().getBusinessTypeNo());*/
        return false;
    }

    public void showPermissionMenu(List<PermissionMenuEntity> data) {
        ArrayList<String> transportMenu = new ArrayList<>();
        if (data != null && data.size() != 0) {
            for (int i = 0; i < data.size(); i++) {
                if (data.get(i).getSort() == 10) { //物流运输(货主)
                    List<PermissionMenuEntity.ListEntity> list = data.get(i).getList();
                    for (PermissionMenuEntity.ListEntity entity : list) {
                        transportMenu.add(entity.getName());
                    }
                    break;
                }
            }
        }
        isHasRightPublishGoodsPutong = transportMenu.contains("10_putonghuoyuan");
        isHasRightPublishGoodsJingjia = transportMenu.contains("10_jingjiahuoyuan");
        isHasRightPublishCarriage = transportMenu.contains("10_chengyunshangji");
    }

    //认证dialog
    public void showDialog(int type) {
        View view = View.inflate(getActivity(), R.layout.dialog_two_btn, null);
        final RoundCornerDialog roundCornerDialog = new RoundCornerDialog(getActivity(), 0, 0, view, R.style.RoundCornerDialog);
        roundCornerDialog.show();
        roundCornerDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失

        TextView tv_message = (TextView) view.findViewById(R.id.tv_message);
        TextView tv_title = view.findViewById(R.id.tv_title);
        TextView tv_logout_confirm = (TextView) view.findViewById(R.id.tv_logout_confirm);
        tv_title.setVisibility(View.VISIBLE);
        TextView tv_logout_cancel = (TextView) view.findViewById(R.id.tv_logout_cancel);
        if (type == 0) {
            tv_title.setText("登录");
            tv_message.setText("请先去登录");
        } else {
            tv_title.setText("认证");
            tv_message.setText("请先进行认证才能操作");
        }

        //确定
        tv_logout_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (type == 0) {
                    EventBus.getDefault().postSticky("transport_to_login");
                } else if (type == 1) {
                    AuthActivity.start(getContext());
                }
                roundCornerDialog.dismiss();
            }
        });

        //取消
        tv_logout_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                roundCornerDialog.dismiss();
            }
        });
    }

    public void showCarInfo(List<CarInfo> carInfo) {
        this.carInfo = carInfo;
    }


    private void showAuthenDialog(int type) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        View layout;

        AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
        switch (type) {
            case 2://司机认证提醒切换
                layout = inflater.inflate(R.layout.dialog_authen_driver_change, null);
                layout.findViewById(R.id.rl_authen_driver).setOnClickListener(view -> {
//                    DialogHelper.showDownloadDialog(getContext());
                    AuthActivity3.start(getContext());
                    mDialog.dismiss();
                });
                break;
            case 3://货主中介认证
                layout = inflater.inflate(R.layout.dialog_authen_owner_zhongjie_change, null);
                layout.findViewById(R.id.rl_authen_owner).setOnClickListener(view -> {
                    AuthActivity3.start(getContext());
                    mDialog.dismiss();
                });
                layout.findViewById(R.id.rl_authen_zhongjie).setOnClickListener(view -> {
                    AuthActivity3.start(getContext());
                    mDialog.dismiss();
                });
                break;
            case 1://司机认证
            default:
                layout = inflater.inflate(R.layout.dialog_authen_driver, null);
                layout.findViewById(R.id.rl_authen_driver).setOnClickListener(view -> {
//                    DialogHelper.showDownloadDialog(getContext());
                    AuthActivity3.start(getContext());
                    mDialog.dismiss();
                });
        }

        builder.setView(layout);
        builder.setCancelable(true);
        mDialog = builder.show();
        mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

        DisplayMetrics dm = new DisplayMetrics();
        //获取屏幕信息
        dm = getContext().getResources().getDisplayMetrics();
        int screenWidth = dm.widthPixels;
        int screenHeigh = dm.heightPixels;
        CardView cv = mDialog.findViewById(R.id.cv_dialog);
        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) cv.getLayoutParams(); //取控件textView当前的布局参数
        linearParams.width = screenWidth - 100;//
//        linearParams.height = screenHeigh / 3;//
        cv.setLayoutParams(linearParams);

        mDialog.findViewById(R.id.iv_cancel).setOnClickListener(v -> mDialog.dismiss());

    }

    @SuppressLint({"AutoDispose", "CheckResult"})
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(LogisticsEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_LOGISTICS_WINDOW_TOP) {
            binding.appBarLayout.setExpanded(false);
//            Observable.timer(300, TimeUnit.MILLISECONDS)
//                    .subscribeOn(Schedulers.io())
//                    .observeOn(AndroidSchedulers.mainThread())
//                    .subscribe(aLong -> {
//                    });

        } else if (event.getMessageTag() == EventConstant.EVENT_LOGISTICS_WINDOW_SHOW) {
//            mHandler.sendMessageDelayed(new Message(), 700);

        } else if (event.getMessageTag() == EventConstant.EVENT_LOGISTICS_WINDOW_HIDE) {
//            binding.bgPopGrayLayout.setVisibility(View.GONE);
//            binding.drawerLayout.closeDrawer(Gravity.RIGHT);
        } else if (event != null && event.getMessageTag() == EventConstant.EVENT_CARINFO_COMMIT) {//接收新增车辆或完善车辆认证信息事件
            binding.carImperfect.setVisibility(View.GONE);
            checkUserCarInfo();
        } else if (event != null && event.getMessageTag() == EventConstant.EVENT_ADDRESS_SELECTED) {//找车/找货地址选择结果
            AMapAddressEntity addressEntity = (AMapAddressEntity) event.getObject();
            if (addressEntity != null) {
                if (addressEntity.getType() == 0) {
                    startAddress = addressEntity;
                    binding.loadPlaceEdit.setText(startAddress.getSnippet());
                } else if (addressEntity.getType() == 1) {
                    endAddress = addressEntity;
                    binding.unloadPlaceEdit.setText(endAddress.getSnippet());
                    binding.unloadPlaceEdit.setTextColor(Color.parseColor("#333333"));
                }
            }
        }
    }

    private String goodsTypeNo = "";

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(GoodsSourceSearchEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_FILTER_OPEN) {
            if (TextUtils.isEmpty(event.getNo()) || event.getNo().equals(DEFAULT_GOODS_TYPE)) {
                goodsTypeNo = "";
            } else {
                goodsTypeNo = event.getNo();
            }
            binding.appBarLayout.setExpanded(false);

            if (!model.isContainCarTypeAndCarLengthByGoodsNo(goodsTypeNo)) {
                model.getCarTypeAndCarLengthList(goodsTypeNo);
            } else
                setCarTypeAndCarLength(model.allCarTypeAndCarLengthMap.get(goodsTypeNo));
        }
    }

    //开通个人资金账户后判断
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getCode(MessageEvent event) {
        switch (event.code) {
            case EventConstant.EVENT_REFRESH:
                UserOperating.getInstance().refresh();
                break;
        }
    }

    public void showCarInfoResult(boolean isComplete, CarInfo carInfo) {
        if (!isComplete) {
            this.carInfoEntity = carInfo;
            binding.carImperfect.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 更多筛选  抽屉相关
     */
    private static final float WEIGHT_MAX_VALUE = 999.9f;
    private static final float VOLUME_MIN_VALUE = 0f;
    private static final float VOLUME_MAX_VALUE = 999.9f;
    public static final String DEFAULT_GOODS_TYPE = "Default_GoodsType";
    private GoodsHallFilterEntity goodsSourceFilterEntity;
    private WeightAndVolumeMinAndMaxAdapter weightAdapter;
    private WeightAndVolumeMinAndMaxAdapter volumeAdapter;
    private CarTypeTransportAdapter3 carTypeAdapter;
    private CarLengthTransportAdapter3 lengthAdapter;
    private String currentGoodsType = DEFAULT_GOODS_TYPE;
    private String goodsType = "";

    private Map<String, List<GoodsInfoTypeEntity3>> carTypeNoAndCarLengthMap = new HashMap<>();
    private List<GoodsInfoTypeEntity3> allCarsTypeList = new ArrayList<>();
    private List<GoodsInfoTypeEntity3> usefulCarsTypeList = new ArrayList<>();
    private List<GoodsInfoTypeEntity3> usefulCarsLengthList = new ArrayList<>();
    private List<GoodsInfoTypeEntity3> currentTypeList = new ArrayList<>();
    private List<GoodsInfoTypeEntity3> lengthtempList = new ArrayList<>();
    private List<GoodsInfoTypeEntity3> lastCarLengthCheckedData = new ArrayList<>();
    private List<GoodsInfoTypeEntity3> lastCarTypeCheckedData = new ArrayList<>();

    //选中却不可见的车型数据
    private List<GoodsInfoTypeEntity3> invisibleCheckedCarTypes = new ArrayList<>();
    //选中却不可见的车长数据
    private List<GoodsInfoTypeEntity3> invisibleCheckedCarLength = new ArrayList<>();

    /**
     * 给抽屉填充数据
     *
     * @param carTypeAndCarLength
     */
    public void setCarTypeAndCarLength(List<CarTypeAndCarLength> carTypeAndCarLength) {
        if (carTypeAndCarLength == null) {
            return;
        }

        //如果要展示的货物类型和上次的货物类型不相同，就重置记录的选中数据
        if (!currentGoodsTypeIsSameWithLast(goodsType)) {
            this.currentGoodsType = goodsType;
            clearCarTypeAndCarLengthChecked();
            resetVolume();
            resetWeight();
        }

        resetCarType();
        convertToUsefulCarsTypeList(carTypeAndCarLength);
        //显示车型
        resetCarType();
        setCarTypeShowState(true);

        //显示车长
        boolean lastSelectedCarType = lastCarTypeCheckedData != null && lastCarTypeCheckedData.size() != 0;
        if (lastSelectedCarType) {
            refreshCarLengthByCarType(lastCarTypeCheckedData);
        } else {
            refreshCarLengthByCarType(usefulCarsTypeList);
        }
        binding.drawerLayout.openDrawer(Gravity.RIGHT);
    }

    private void clearCarTypeAndCarLengthChecked() {
        lastCarTypeCheckedData.clear();
        lastCarLengthCheckedData.clear();
    }

    private void convertToUsefulCarsTypeList(List<CarTypeAndCarLength> carTypeAndCarLength) {
        allCarsTypeList.clear();
        carTypeNoAndCarLengthMap.clear();
        for (CarTypeAndCarLength item : carTypeAndCarLength) {
            allCarsTypeList.add(new GoodsInfoTypeEntity3(item.getNo(), item.getName()));
            carTypeNoAndCarLengthMap.put(item.getNo(), item.getCarLenList());
        }
    }

    private void addCarLengthDefaultItem() {
        if (usefulCarsLengthList == null ||
                (usefulCarsLengthList.size() >= 1 && usefulCarsLengthList.get(0).getName().equals("不限"))) {
            return;
        }
        GoodsInfoTypeEntity3 entity3 = new GoodsInfoTypeEntity3();
        entity3.setNo(DEFAULT_GOODS_TYPE);
        entity3.setName("不限");
        usefulCarsLengthList.add(0, entity3);
    }

    private void addCarTypeDefaultItem() {
        if (usefulCarsTypeList == null ||
                (usefulCarsTypeList.size() >= 1 && usefulCarsTypeList.get(0).getName().equals("不限"))) {
            return;
        }
        GoodsInfoTypeEntity3 entity3 = new GoodsInfoTypeEntity3();
        entity3.setNo(DEFAULT_GOODS_TYPE);
        entity3.setName("不限");
        usefulCarsTypeList.add(0, entity3);
    }

    private void foldCarTypeData(boolean isFold) {
        if (null == usefulCarsTypeList) {
            return;
        }
        invisibleCheckedCarTypes.clear();
        if (isFold) {
            if (usefulCarsTypeList.size() > 9) {
                currentTypeList = usefulCarsTypeList.subList(0, 9);
                binding.carTypeMore.setImageResource(R.drawable.common_shouqi);
                //对于被选中但是却隐藏掉的数据进行保存
                if (lastCarTypeCheckedData.size() > 0) {
                    for (int i = 0; i < usefulCarsTypeList.size(); i++) {
                        for (int i1 = 0; i1 < lastCarTypeCheckedData.size(); i1++) {
                            if (lastCarTypeCheckedData.get(i1).getNo().equals(usefulCarsTypeList.get(i).getNo())) {
                                invisibleCheckedCarTypes.add(lastCarTypeCheckedData.get(i1));
                            }
                        }
                    }
                }
            } else {
                currentTypeList = usefulCarsTypeList;
                binding.carTypeMore.setImageResource(R.drawable.common_zhankai);
            }
        } else {
            currentTypeList = usefulCarsTypeList;
            binding.carTypeMore.setImageResource(R.drawable.common_zhankai);
        }
    }

    private void setCarTypeShowState(boolean isFoldCarType) {
        if (null != usefulCarsTypeList) {
            foldCarTypeData(isFoldCarType);
            carTypeAdapter.setDatas(currentTypeList);
            carTypeAdapter.resetCheckDatas();
            if (lastCarTypeCheckedData == null || lastCarTypeCheckedData.size() == 0) {
                carTypeAdapter.setCheckDefault(0);
                binding.choosedCartype.setText("");
                return;
            }

            StringBuilder lastCarTypeCheckedStr = new StringBuilder();
            for (GoodsInfoTypeEntity3 item : lastCarTypeCheckedData) {
                if (currentTypeList.contains(item)) {
                    carTypeAdapter.setCheckDefault(currentTypeList.indexOf(item));
                }
                if (!TextUtils.isEmpty(item.getNo()) && !TextUtils.isEmpty(item.getNo())) {
                    lastCarTypeCheckedStr.append(item.getName());
                    lastCarTypeCheckedStr.append(",");
                }
            }
            if (lastCarTypeCheckedStr.length() > 1)
                binding.choosedCartype.setText(lastCarTypeCheckedStr.substring(0, lastCarTypeCheckedStr.length() - 1));
        } else {
            binding.carTypeMore.setImageResource(R.drawable.common_shouqi);
            binding.choosedCartype.setText("");
        }
    }


    private void foldCarLengthData(boolean isFold) {
        if (null == usefulCarsLengthList) {
            return;
        }
        invisibleCheckedCarLength.clear();
        if (isFold) {
            if (usefulCarsLengthList.size() > 9) {
                lengthtempList = usefulCarsLengthList.subList(0, 9);
                binding.carLengthMore.setImageResource(R.drawable.common_shouqi);
                //对于被选中但是却隐藏掉的数据进行保存
                if (lastCarLengthCheckedData.size() > 0) {
                    for (int i = 0; i < usefulCarsLengthList.size(); i++) {
                        for (int i1 = 0; i1 < lastCarLengthCheckedData.size(); i1++) {
                            if (lastCarLengthCheckedData.get(i1).getNo().equals(usefulCarsLengthList.get(i).getNo())) {
                                invisibleCheckedCarLength.add(lastCarLengthCheckedData.get(i1));
                            }
                        }
                    }
                }
            } else {
                lengthtempList = usefulCarsLengthList;
                binding.carLengthMore.setImageResource(R.drawable.common_zhankai);
            }
        } else {
            lengthtempList = usefulCarsLengthList;
            binding.carLengthMore.setImageResource(R.drawable.common_zhankai);
        }
    }

    private void setCarLengthShowState(boolean isFold) {
        if (null != usefulCarsLengthList) {
            refreshLastCheckedLength();
            foldCarLengthData(isFold);
            lengthAdapter.setDatas(lengthtempList);
            lengthAdapter.resetCheckDatas();
            //当上次选中的车长，在变更车型后依然有效的需要保证继续选中
            if (lastCarLengthCheckedData == null || lastCarLengthCheckedData.size() == 0) {
                lengthAdapter.setCheckDefault(0);
                binding.choosedCartlen.setText("");
                return;
            }
            StringBuilder lastCarLenCheckedStr = new StringBuilder();
            if (lastCarLengthCheckedData.size() > 0) {
                for (GoodsInfoTypeEntity3 item : lastCarLengthCheckedData) {
                    if (lengthtempList.contains(item)) {
                        lengthAdapter.setCheckDefault(lengthtempList.indexOf(item));
                    }
                    if (!TextUtils.isEmpty(item.getName()) && !TextUtils.isEmpty(item.getNo())) {
                        lastCarLenCheckedStr.append(item.getName());
                        lastCarLenCheckedStr.append(",");
                    }
                }
            }

            if (TextUtils.isEmpty(lastCarLenCheckedStr)) {
                return;
            }
            binding.choosedCartlen.setText(lastCarLenCheckedStr.substring(0, lastCarLenCheckedStr.length() - 1));
        } else {
            lengthAdapter.resetCheckDatas();
            binding.choosedCartlen.setText("");
            lastCarLengthCheckedData.clear();
        }
    }

    public void refreshCarLengthByCarType(List<GoodsInfoTypeEntity3> carTypes) {
        if (carTypes == null || carTypes.size() == 0) {
            lengthAdapter.setDatas(new ArrayList<>());
            return;
        }
        usefulCarsLengthList.clear();
        for (GoodsInfoTypeEntity3 item : carTypes) {
            List<GoodsInfoTypeEntity3> infoTypeEntity3s = carTypeNoAndCarLengthMap.get(item.getNo());
            if (infoTypeEntity3s == null || infoTypeEntity3s.size() == 0) {
                continue;
            }
            usefulCarsLengthList.addAll(infoTypeEntity3s);
        }
        VehicleConstant.sortCarLength(usefulCarsLengthList);
        removeDuplicateCarLength();
        addCarLengthDefaultItem();
        setCarLengthShowState(true);
    }

    private void refreshLastCheckedLength() {
        //获取上次选中的车长中在当前车型中仍然有效的车长
        List<GoodsInfoTypeEntity3> usefulCheckedLength = new ArrayList<>();
        for (GoodsInfoTypeEntity3 item : lastCarLengthCheckedData) {
            if (usefulCarsLengthList.contains(item)) {
                usefulCheckedLength.add(item);
            }
        }

        lastCarLengthCheckedData.clear();
        boolean isCheckedFirstItem = lengthAdapter.getCheckDatas().size() >= 1 &&
                lengthAdapter.getCheckDatas().get(0).getName().equals("不限");
        if (isCheckedFirstItem) {
            return;
        }

        lastCarLengthCheckedData.addAll(usefulCheckedLength);
        lastCarLengthCheckedData.addAll(lengthAdapter.getCheckDatas());
        lastCarLengthCheckedData = removeDuplicate(lastCarLengthCheckedData);
    }

    private void refreshLastCheckedCarType() {
        //获取上次选中的车型中在当前货物类型中仍然有效的车型
        List<GoodsInfoTypeEntity3> usefulCheckedCarTypes = new ArrayList<>();
        for (GoodsInfoTypeEntity3 item : lastCarTypeCheckedData) {
            if (usefulCarsTypeList.contains(item)) {
                usefulCheckedCarTypes.add(item);
            }
        }

        lastCarTypeCheckedData.clear();
        boolean isCheckedFirstItem = carTypeAdapter.getCheckDatas().size() >= 1 &&
                carTypeAdapter.getCheckDatas().get(0).getName().equals("不限");
        if (isCheckedFirstItem) {
            return;
        }

        lastCarTypeCheckedData.addAll(usefulCheckedCarTypes);
        lastCarTypeCheckedData.addAll(carTypeAdapter.getCheckDatas());
        lastCarTypeCheckedData = removeDuplicate(lastCarTypeCheckedData);
    }

    private void removeDuplicateCarLength() {
        usefulCarsLengthList.removeAll(Collections.singleton(null));
        LinkedHashSet<GoodsInfoTypeEntity3> set = new LinkedHashSet<>();
        set.addAll(usefulCarsLengthList);
        usefulCarsLengthList = new ArrayList<>(set);
    }

    private List<GoodsInfoTypeEntity3> removeDuplicate(List<GoodsInfoTypeEntity3> list) {
        if (list == null || list.size() == 0) return new ArrayList<>();
        list.removeAll(Collections.singleton(null));
        LinkedHashSet<GoodsInfoTypeEntity3> set = new LinkedHashSet<>();
        set.addAll(list);
        return new ArrayList<>(set);
    }

    /**
     * 初始化车型选择相关控件
     */
    private void initCarTypeView() {
        carTypeAdapter = new CarTypeTransportAdapter3(mContext, null);
        binding.goodsCarTypeList.setLayoutManager(new GridLayoutManager(mContext, 3));
        binding.goodsCarTypeList.setAdapter(carTypeAdapter);
        carTypeAdapter.setMultiSelect(true);
        carTypeAdapter.setLimit(true);
        carTypeAdapter.setOnItemMultiClick((goodsInfoTypeEntity3s, position) -> {
            lastCarTypeCheckedData.clear();
            if (goodsInfoTypeEntity3s != null && goodsInfoTypeEntity3s.size() > 0)
                lastCarTypeCheckedData.addAll(goodsInfoTypeEntity3s);
            if (invisibleCheckedCarTypes.size() > 0)
                lastCarTypeCheckedData.addAll(invisibleCheckedCarTypes);
            showCheckedCarType();
            //没有选中任何车型（包括不限），车长显示为空
            if (lastCarTypeCheckedData.size() == 0) {
                refreshCarLengthByCarType(null);
                return;
            }

            if (goodsInfoTypeEntity3s != null && goodsInfoTypeEntity3s.size() > 0) {
                if (goodsInfoTypeEntity3s.get(0).getName().equals("不限")) {//选中不限
                    refreshCarLengthByCarType(allCarsTypeList);
                    return;
                }
            }
            //选中的有效车型
            refreshCarLengthByCarType(lastCarTypeCheckedData);

        });
        binding.carTypeMore.setOnClickListener(this::onClick);
    }

    /**
     * 车长选择显示处理
     */
    private void showCheckedCarLen() {
        if ((lengthAdapter.getCheckDatas() == null || lengthAdapter.getCheckDatas().size() < 1) && invisibleCheckedCarLength.size() < 1) {////没有选中任何可见选项并且也没有隐藏的选中项
            binding.choosedCartlen.setText("");
        } else if (lengthAdapter.getCheckDatas() != null && lengthAdapter.getCheckDatas().size() > 0
                && lengthAdapter.getCheckDatas().get(0).getName().equals("不限")) {//选中了不限
            binding.choosedCartlen.setText("");
            lastCarLengthCheckedData.clear();
            lastCarLengthCheckedData.add(lengthAdapter.getCheckDatas().get(0));
        } else {//选中了“不限”以外的选项
            if (lastCarLengthCheckedData.size() > 0) {
                VehicleConstant.sortCarLength(lastCarLengthCheckedData);
                StringBuilder carLenCheckedStr = new StringBuilder();
                for (GoodsInfoTypeEntity3 item : lastCarLengthCheckedData) {
                    carLenCheckedStr.append(item.getName());
                    carLenCheckedStr.append(",");
                }
                binding.choosedCartlen.setText(carLenCheckedStr.substring(0, carLenCheckedStr.length() - 1));
            } else {
                binding.choosedCartlen.setText("");
            }
        }
    }

    /**
     * 车型选择显示处理
     */
    private void showCheckedCarType() {
        if ((carTypeAdapter.getCheckDatas() == null || carTypeAdapter.getCheckDatas().size() < 1) && invisibleCheckedCarTypes.size() < 1) {//没有选中任何可见选项并且也没有隐藏的选中项
            binding.choosedCartype.setText("");
            binding.choosedCartlen.setText("");
        } else if (carTypeAdapter.getCheckDatas() != null && carTypeAdapter.getCheckDatas().size() > 0
                && carTypeAdapter.getCheckDatas().get(0).getName().equals("不限")) {//选中了不限
            binding.choosedCartype.setText("");
            lastCarTypeCheckedData.clear();
            lastCarTypeCheckedData.add(carTypeAdapter.getCheckDatas().get(0));
        } else {//选中了“不限”以外的选项
            if (lastCarTypeCheckedData.size() > 0) {
                StringBuilder carTypeCheckedStr = new StringBuilder();
                for (GoodsInfoTypeEntity3 item : lastCarTypeCheckedData) {
                    carTypeCheckedStr.append(item.getName());
                    carTypeCheckedStr.append(",");
                }
                binding.choosedCartype.setText(carTypeCheckedStr.substring(0, carTypeCheckedStr.length() - 1));
            } else {
                binding.choosedCartype.setText("");
            }
        }
    }

    /**
     * 初始化车长选择相关控件
     */
    private void initCarLengthView() {
        lengthAdapter = new CarLengthTransportAdapter3(mContext, null);
        binding.goodsCarLengthList.setLayoutManager(new GridLayoutManager(mContext, 3));
        binding.goodsCarLengthList.setAdapter(lengthAdapter);
        lengthAdapter.setMultiSelect(true);
        lengthAdapter.setLimit(true);
        lengthAdapter.setDefItem(-1);
        binding.carLengthMore.setOnClickListener(this::onClick);
        lengthAdapter.setOnItemMultiClick((goodsInfoTypeEntity3s, position) -> {
            lastCarLengthCheckedData.clear();
            if (goodsInfoTypeEntity3s != null && goodsInfoTypeEntity3s.size() > 0)
                lastCarLengthCheckedData.addAll(goodsInfoTypeEntity3s);
            if (invisibleCheckedCarLength.size() > 0)
                lastCarLengthCheckedData.addAll(invisibleCheckedCarLength);
            showCheckedCarLen();
        });
    }

    public void resetAllFilterData() {
        carTypeAdapter.resetCheckDatas();
        carTypeAdapter.setDefItem(-1);
        lengthAdapter.resetCheckDatas();
        lengthAdapter.setDefItem(-1);
        lastCarLengthCheckedData.clear();
        lastCarTypeCheckedData.clear();
        resetCarTypeAndCarLength();
        resetVolume();
        resetWeight();

        goodsSourceFilterEntity.setLengthType(null);
        goodsSourceFilterEntity.setCarType(null);
    }

    private void resetCarTypeAndCarLength() {
        resetCarType();
        refreshCarLengthByCarType(usefulCarsTypeList);
        setCarTypeShowState(true);
    }

    private void resetCarType() {
        resetCarType(true);
    }

    private void resetCarType(boolean isAddDefaultItem) {
        usefulCarsTypeList = allCarsTypeList;
        if (isAddDefaultItem) {
            addCarTypeDefaultItem();
        }
    }

    private void initVolumeRecyclerView() {
        List<WeightAndVolumeEntity> datas = new ArrayList<>();
        datas.add(new WeightAndVolumeEntity(0, 10));
        datas.add(new WeightAndVolumeEntity(10, 20));
        datas.add(new WeightAndVolumeEntity(20, 30));
        datas.add(new WeightAndVolumeEntity(30, 40));
        datas.add(new WeightAndVolumeEntity(40, 50));
        datas.add(new WeightAndVolumeEntity(50, VOLUME_MAX_VALUE));
        volumeAdapter = new WeightAndVolumeMinAndMaxAdapter(mContext, datas);
        volumeAdapter.setMultiSelect(false);
        volumeAdapter.setItemSelect(true);
        volumeAdapter.setDefItem(-1);
        volumeAdapter.setOnItemClick(new TransportAdapterOnItemClick<WeightAndVolumeEntity>() {
            @Override
            public void onItemClick(WeightAndVolumeEntity weightAndVolumeEntity, int position) {
                goodsSourceFilterEntity.setVolume(weightAndVolumeEntity.getMin());
                goodsSourceFilterEntity.setMaxVolume(weightAndVolumeEntity.getMax());
                binding.choosedVolume.setText(weightAndVolumeEntity.toString());
            }
        });
        binding.volumeRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
        binding.volumeRecyclerView.setAdapter(volumeAdapter);
    }

    private void initWeightRecyclerView() {
        List<WeightAndVolumeEntity> datas = new ArrayList<>();
        datas.add(new WeightAndVolumeEntity(0, 5));
        datas.add(new WeightAndVolumeEntity(5, 10));
        datas.add(new WeightAndVolumeEntity(10, 15));
        datas.add(new WeightAndVolumeEntity(15, 20));
        datas.add(new WeightAndVolumeEntity(20, WEIGHT_MAX_VALUE));
        weightAdapter = new WeightAndVolumeMinAndMaxAdapter(mContext, datas);
        weightAdapter.setMultiSelect(false);
        weightAdapter.setItemSelect(true);
        weightAdapter.setOnItemClick(new TransportAdapterOnItemClick<WeightAndVolumeEntity>() {
            @Override
            public void onItemClick(WeightAndVolumeEntity weightAndVolumeEntity, int position) {
                goodsSourceFilterEntity.setMinWeight(String.valueOf(weightAndVolumeEntity.getMin()));
                goodsSourceFilterEntity.setMaxWeight(String.valueOf(weightAndVolumeEntity.getMax()));
                binding.choosedWieght.setText(weightAndVolumeEntity.toString());
            }
        });
        binding.weightRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
        binding.weightRecyclerView.setAdapter(weightAdapter);
    }

    private void resetWeight() {
        binding.choosedWieght.setText("");
        weightAdapter.resetCheckDatas();
        weightAdapter.setDefItem(-1);
        goodsSourceFilterEntity.setMaxWeight(null);
        goodsSourceFilterEntity.setMinWeight(null);
    }

    private void resetVolume() {
        binding.choosedVolume.setText("");
        volumeAdapter.resetCheckDatas();
        volumeAdapter.setDefItem(-1);
        goodsSourceFilterEntity.setVolume(VOLUME_MIN_VALUE);
        goodsSourceFilterEntity.setMaxVolume(VOLUME_MAX_VALUE);
    }

    public boolean isChooseFirstDefaultItem(List<GoodsInfoTypeEntity3> list) {
        if (list != null && list.size() >= 1) {
            return list.get(0).getName().equals("不限");
        }
        return false;
    }

    private boolean currentGoodsTypeIsSameWithLast(String goodsType) {
        if (TextUtils.isEmpty(goodsType)) return false;
        return goodsType.equals(currentGoodsType);
    }

    private void addMarkerCars(List<VehicleHallMapEntity> list) {
        aMap.clear();
        for (VehicleHallMapEntity entity : list) {
            if (entity != null && entity.getLatitude() != null && entity.getLongitude() != null) {
                LatLng latLng = new LatLng(NumberUtil.convertToDouble(String.valueOf(entity.getLatitude())), NumberUtil.convertToDouble(String.valueOf(entity.getLongitude())));
                BitmapDescriptor bitmapSmall = BitmapDescriptorFactory.fromResource(R.mipmap.icon_car_freight_home);
                MarkerOptions markerOption = new MarkerOptions()
                        .position(latLng)
                        .icon(bitmapSmall)
                        .draggable(false);
                aMap.addMarker(markerOption);
            }
        }
//        if (latLng != null)
//            aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 10f));
    }


    private void addMarkerGoods(List<MapSourcesEntity> list) {
        aMap.clear();
        for (MapSourcesEntity entity : list) {
            LatLng latLng = new LatLng(NumberUtil.convertToDouble(entity.getLatitude()), NumberUtil.convertToDouble(entity.getLongitude()));
            BitmapDescriptor bitmapNormal = BitmapDescriptorFactory.fromResource(R.mipmap.icon_common_home);
            MarkerOptions markerNormal;

            BitmapDescriptor bitmapJingJia = BitmapDescriptorFactory.fromResource(R.mipmap.icon_jingjia_home);
            MarkerOptions markerJingjia;
            if (entity.getPattern() == 1) {
                markerJingjia = new MarkerOptions().position(latLng).icon(bitmapJingJia).draggable(false);
                aMap.addMarker(markerJingjia);
            } else {
                markerNormal = new MarkerOptions().position(latLng).icon(bitmapNormal).draggable(false);
                aMap.addMarker(markerNormal);
            }
        }
    }

    /**
     * event监听登录和登出的状态
     */
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(LoginEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_LOGIN) {
            if (mListMember != null)
                mListMember.clear();
            if (mListLeague != null)
                mListLeague.clear();
            if (mListFocus != null)
                mListFocus.clear();

            if (adapter != null && adapter.getCheckDatas() != null && adapter.getCheckDatas().size() > 0) {
                PickFilterEntity currentItem = adapter.getCheckDatas().get(0);
                if (currentItem.getName().equals("会员")) {
                    model.getLeaguerList(2);
                } else if (currentItem.getName().equals("成员")) {
                    model.getLeaguerList(1);
                } else if (currentItem.getName().equals("关注")) {
                    model.getAttendCompanyList(1, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""));
                } else if (currentItem.getName().equals("推荐")) {
                    binding.llManageList.setVisibility(View.GONE);
                    binding.tvManageEmpty.setVisibility(View.VISIBLE);
                    binding.tvInviteType.setVisibility(View.GONE);
                    binding.tvManageEmpty.setText("暂无数据");
                }
            }
        } else if (event.getMessageTag() == EventConstant.EVENT_LOGIN_OUT) {
            if (mListMember != null)
                mListMember.clear();
            if (mListLeague != null)
                mListLeague.clear();
            if (mListFocus != null)
                mListFocus.clear();
            if (companyListAdapter != null)
                companyListAdapter.setDatas(null);
            binding.llManageList.setVisibility(View.GONE);
            binding.tvManageEmpty.setVisibility(View.VISIBLE);
            binding.tvInviteType.setVisibility(View.GONE);
            binding.tvManageEmpty.setText("您暂未登录，请登录后查看");
//            if (adapter != null && adapter.getCheckDatas() != null && adapter.getCheckDatas().size() > 0) {
//                PickFilterEntity currentItem = adapter.getCheckDatas().get(0);
//                if (currentItem.getName().equals("会员")) {
//                    binding.tvManageEmpty.setText("您还没有会员企业，快去邀请吧！");
//                } else if (currentItem.getName().equals("成员")) {
//                    binding.tvManageEmpty.setText("您还没有成员企业，快去邀请吧！");
//                }
//            }
        }
    }

    /**
     * 设置背景颜色变暗
     *
     * @param proportion 设置背景透明度的系数
     */
    private void setBgDim(float proportion) {
        WindowManager.LayoutParams lp = this.getActivity().getWindow().getAttributes();
        lp.alpha = proportion;
        this.getActivity().getWindow().setAttributes(lp);
    }
}
